package net.asg.games.yokeltowers.models;

import net.asg.games.yokeltowers.view.BlockYokelGameObject;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;

public class YokelGameBoard {
	final private int BOARD_LENGTH = 6;
	final private int BOARD_HEIGHT = 15;
	final public int BOARD_ROW_LIMIT = 14;
	protected int playerID;
	protected int boardID;
	
	public Array<BlockYokelGameObject> playerBoard;
	
	public YokelGameBoard(){
		clearBoard(playerBoard);
	}
	
	public void putBlock(int row, int col, BlockYokelGameObject block){
		playerBoard.set(row * BOARD_LENGTH + col, block);
	}
	
	public BlockYokelGameObject getBlock(int row, int col){
		return playerBoard.get(row * BOARD_LENGTH + col);
	}
	
	public void removeBlock(int row, int col){
		putBlock(row,col,null);
	}

	public void deleteRow(int row){
		
	}
	
	public void addRow(int row){
		
	}
	
	public void clearBoard(Array<BlockYokelGameObject> playerBoard){
		if (playerBoard != null)
			playerBoard.clear();
		for(int i = 0; i < BOARD_LENGTH * BOARD_HEIGHT; i++){
			playerBoard.add(null);
		}
	}
	
	public void drawBoard(SpriteBatch batch){
		int row = 0;
		int col = 0;
		for(int i = 0; i < BOARD_LENGTH * BOARD_HEIGHT; i++){
			playerBoard.get(row * BOARD_LENGTH + col).draw(batch);
			if (col < BOARD_LENGTH){
				col++;
			} else {
				col = 0;
				row++;
			}
		}
	}
	
}
